/*
 * @Author: chuangshishen abc@163.com
 * @Date: 2023-06-25 18:42:08
 * @LastEditors: chuangshishen abc@163.com
 * @LastEditTime: 2023-06-25 19:11:38
 * @FilePath: \vscodeFile\vue\my-graduate-project-vue\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {createRouter, createWebHistory} from "vue-router";
import home from '@/view'
import {ElLoading} from "element-plus";

const routes = [
    // 注意这里使用路由path:'/'，Home, 如果你在app.vue  已经加载了首页，要删除app.vue中的组件，不然会重复加载
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        component: home,
        redirect: '/home/index',
        children: [
            {
                path: "index",
                component: () => import('@/view/homeBody/index'),
            },
            {
                path: 'commodity-search',
                component: () => import('@/view/homeBody/CommoditySearch')
            },
            {
                path: 'commodity-detail',
                component: () => import('@/view/homeBody/CommodityDetail.vue')
            },

            {
                path: 'other',
                component: () => import('@/view/homeBody/Other')
            },
            {
                path: 'friend',
                component: () => import('@/view/homeBody/Friend')
            },
            {
                path: 'second',
                component: () => import('@/view/homeBody/Second')
            },
        ]
    },
    {
        path: '/square',
        component: () => import('@/view/square/Square')
    },

    {
        path: '/square-content',
        component: () => import('@/view/square/SquareContent.vue')
    },
    {
        path: "/flashSale",
        component: () => import('@/view/commodity/flashSale')
    },
    {
        path: '/login',
        component: () => import('@/view/login.vue')
    },
    {
        path: '/reset-password',
        component: () => import('@/view/ResetPassword')
    },
    {
        path: '/order-confirm',
        component: () => import('@/view/order/OrderConfirm')
    }, {
        path: '/order-detail',
        component: () => import('@/view/order/OrderDetail')
    }, {
        path: '/commodity-appraise',
        component: () => import('@/view/commodity/CommodityAppraise')
    },
    {
        path: '/person',
        component: () => import('@/view/person/Person'),
        redirect: '/person/personal-information',
        children: [
            {
                path: 'personal-information',
                component: () => import('@/view/person/PersonalInformation')
            },
            {
                path: 'person-cart',
                component: () => import('@/view/person/PersonCart')
            },
            {
                path: 'person-address',
                component: () => import('@/view/person/PersonAddress')
            },
            {
                path: 'person-appraise',
                component: () => import('@/view/person/PersonAppraise')
            },
            {
                path: 'person-order',
                component: () => import('@/view/person/PersonOrder')
            },
            {
                path: 'person-message',
                component: () => import('@/view/person/PersonMessage')
            },
            {
                path: 'square-add',
                component: () => import('@/view/square/AddSquare')
            },
        ],
    }
]
const routerHistory = createWebHistory()
const routers = createRouter({
    history: routerHistory,
    routes: routes,
})
routers.afterEach((to, from, next) => {
    const loading = ElLoading.service({
        lock: true,
        text: '正在使劲加载...',
        background: 'rgba(0, 0, 0, 0.7)',
    })
    setTimeout(() => {
        loading.close()
    }, 2000)
})
export default routers
